package utils;

import java.util.Iterator;

public class Fibiterator implements Iterator<Long>{
	private long a = 0L;
	private long b = 1L;
	
	@Override
	public boolean hasNext() {
		return true;
	}

	@Override
	public Long next() {
		if (b < 0) {
			throw new IllegalStateException("Overflow!");
		}
		long c = a + b;
		a = b;
		b = c;
		return a;
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}
}
